{% extends "base.html" %}

{% block main %}
    <div class="container">
       <div class="my-3 p-3 bg-white rounded box-shadow">
            <form action="{% url 'users:user_login' %}" method="post">
              <div class="form-group">
                <label for="id_email">邮箱地址</label>
                <input type="email" class="form-control {% if 'email' in invalid_keys %}is-invalid{% endif %}" id="id_email" name="email" aria-describedby="emailHelp" required placeholder="输入邮箱">
                <small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
              </div>
              <div class="form-group">
                <label for="id_password">登录密码</label>
                <input type="password" class="form-control {% if 'password' in invalid_keys %}is-invalid{% endif %}" id="id_password" name="password" required placeholder="输入密码">
              </div>
              <div class="form-group">
                <label>还没有账号？<a href="{% url 'users:user_register' %}">点击注册</a></label>
              </div>
                {% csrf_token %}
              <button type="submit" class="btn btn-success">登录</button>
            </form>
           {% if msg or user_login_form.errors.items %}
               <div class="alert alert-danger alert-dismissible fade show mt-2" role="alert">
                    {% for key, error in user_login_form.errors.items %}
                        {{ error }}
                    {% endfor %}
                    {{ msg }}
                  <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                  </button>
                </div>
           {% endif %}
       </div>
    </div>
{% endblock %}

